//面包屑
// new Vue().$mount('#crumbs');

var msgDetail = new Vue({
    el: "#msgDetail",
    data: function () {
        return {
            title: '回复详情',
            dialogVisible: false,
            labelPosition: 'right',
            replyName: '',
            replyContent: ''
        };
    },
    methods: {
        show: function () {
            this.dialogVisible = true;
        },
        hide: function () {
            this.dialogVisible = false;
        },
        getData: function (replyId) {
            VanyAjax("/sendedmsg/getReplyMsgDetail", {
                replyId: replyId
            }).done(function (data) {
                this.replyContent = data.replyContent;
                this.replyName = data.userName;

            }, false, this);
        }
    }
});
var sm = new Vue({
    el: "#messagereplystatistic",
    data: function () {
        return {
            content: '',
            loading: true,
            msgId: 'a3f50858-dc0f-4fbf-bf75-001bb7eb727c',
            tableData: [],
            pageIndex: 1,
            pageSize: 10,
            total: 0,
            sels: [],
            visible: true
        }
    },
    methods: {
        search: function () {
            this.getData(this.pageIndex, this.pageSize, this.msgId, this.content);
        },
        getData: function (pageIndex, pageSize, msgId, content) {
            VanyAjax("/sendedmsg/getReplyMessages", {
                pageIndex: pageIndex,
                pageSize: pageSize,
                msgId: msgId,
                content: content
            }, "POST").done(function (data) {
                var msgs = data.list;
                this.tableData = msgs;
                this.total = msgs.length;
                for (var i = 0; i < msgs.length; i++) {
                    this.tableData[i].replyTime = new Date((msgs[i].replyTime)).Format("yyyy-MM-dd hh:mm:ss")
                    this.pageIndex = data.pageNum;
                    this.pageSize = data.pageSize;
                    this.total = data.total;
                    this.loading = false;
                }
            }, false, this);
        },
        batchUpdate: function (auditStatus) {
            if (this.sels.length === 0) {
                this.$alert('请选择要更新的信息。', '提示', {
                    type: 'warning',
                    customClass: "notLoadingThis"
                });
                return false;
            }
            var replymsgIds = this.sels.map(function (replymsg) {
                return replymsg.replyId;
            }).join(",");
            console.log("replymsgIds:" + replymsgIds);
            this.updateStatus(replymsgIds, auditStatus);
        },

        updateStatus: function (replymsgIds, auditStatus) {
            var self = this;
            this.$confirm('确认更新所选信息？', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(function () {
                VanyAjax("/sendedmsg/batchUpdateAuditStatus", {
                    replyIdList: replymsgIds,
                    auditStatus: auditStatus
                }).done(function (rspdata) {
                    this.getData(1, this.pageSize, this.msgId, this.content);
                }, true, self);
            }).catch(function () {
            });
        },

        batchDelete: function () {
            if (this.sels.length === 0) {
                this.$alert('请选择要删除的信息。', '提示', {
                    type: 'warning',
                    customClass: "notLoadingThis"
                });
                return false;
            }
            var replymsgIds = this.sels.map(function (replymsg) {
                return replymsg.replyId;
            }).join(",");
            console.log("replymsgIds:" + replymsgIds);
            this.batchDeleteMsg(replymsgIds);
        },

        batchDeleteMsg: function (replymsgIds) {
            var self = this;
            this.$confirm('确认删除所选信息？', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(function () {
                VanyAjax("/sendedmsg/batchDeleteReplyMsg", {
                    replyIdList: replymsgIds
                }).done(function (rspdata) {
                    this.getData(1, this.pageSize, this.msgId, this.content);
                }, true, self);
            }).catch(function () {
            });
        },

        deleteMsg: function (row) {
            var self = this;
            this.$confirm('确认删除信息？', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(function () {
                VanyAjax("/sendedmsg/deleteReplyMsg", {
                    replyId: row.replyId
                }).done(function (rspdata) {
                    this.getData(1, this.pageSize, this.msgId, this.content);
                }, true, self);
            }).catch(function () {
            });
        },
        getDetail: function (row) {
            msgDetail.show();
            msgDetail.getData(row.replyId);
        },
        handleCurrentChange: function (val) {
            console.log('当前页:' + val);
            this.getData(val, this.pageSize, this.msgId, this.content);
        },

        handleSizeChange: function (val) {
            this.getData(this.pageIndex, val, this.msgId, this.content);
        },

        handleSelectionChange: function (selection) {
            this.sels = selection;
        },
    },
    mounted: function () {
        this.getData(this.pageIndex, this.pageSize, this.msgId, this.content);
    }
})
Date.prototype.Format = function (fmt) {
    var o = {
        "M+": this.getMonth() + 1,                 //月份
        "d+": this.getDate(),                    //日
        "h+": this.getHours(),                   //小时
        "m+": this.getMinutes(),                 //分
        "s+": this.getSeconds(),                 //秒
        "q+": Math.floor((this.getMonth() + 3) / 3), //季度
        "S": this.getMilliseconds()             //毫秒
    };
    if (/(y+)/.test(fmt))
        fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    for (var k in o)
        if (new RegExp("(" + k + ")").test(fmt))
            fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
    return fmt;
};